package com.superquan.selfstudybootmybatis.utils.httpapply;

import com.alibaba.fastjson.JSONObject;
import com.superquan.selfstudybootmybatis.entity.common.RequestParams;
import lombok.extern.slf4j.Slf4j;
import net.minidev.json.JSONUtil;
import org.apache.http.util.EntityUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author zwq
 * @description
 * @date 2022/6/20
 */
@Slf4j
public class SendHttpTest {
    public static void main(String[] args) {
        String url = "https://staging-qr.goodyear.com.cn/api/business-microservice/tail/interactive/updateOrderStatusToRtm";
        RequestParams requestParams = new RequestParams();
        requestParams.setType(1);
        requestParams.setOrderStatus("6");
        requestParams.setSecondLevelOrderStatus("15");
        List<String> orderLists=new ArrayList<>();
        orderLists.add("L2204211629305518390");
        requestParams.setOrderNo(orderLists);
        String params = Objects.toString(requestParams);
//        log.info("请求参数："+params);
        String result = HttpUtil.sendHttp(url, params);
        JSONObject jsonObject = JSONObject.parseObject(result);
        Integer code = jsonObject.getInteger("code");
        String message = jsonObject.getString("message");
        JSONObject data = jsonObject.getJSONObject("data");
        if(0==code){
            String userName = data.getString("userName");
            String password = data.getString("password");
            System.out.println("userName:"+userName+",password:"+password);
        }else{
            System.out.println("请求异常！");
        }

    }
}
